package com.whm.hrmanagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson2.JSONObject;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.whm.common.annotation.Log;
import com.whm.common.core.controller.BaseController;
import com.whm.common.core.domain.AjaxResult;
import com.whm.common.enums.BusinessType;
import com.whm.hrmanagement.domain.OaTrainingInfo;
import com.whm.hrmanagement.service.IOaTrainingInfoService;
import com.whm.common.utils.poi.ExcelUtil;
import com.whm.common.core.page.TableDataInfo;

/**
 * 培训信息记录Controller
 * 
 * @author whm
 * @date 2024-02-19
 */
@RestController
@RequestMapping("/hrmanagement/info")
public class OaTrainingInfoController extends BaseController
{
    @Autowired
    private IOaTrainingInfoService oaTrainingInfoService;

    /**
     * 查询培训信息记录列表
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(OaTrainingInfo oaTrainingInfo)
    {
//        startPage();
        List<OaTrainingInfo> list = oaTrainingInfoService.selectOaTrainingInfoList(oaTrainingInfo);
        return getDataTable(list);
    }

    /**
     * 导出培训信息记录列表
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:info:export')")
    @Log(title = "培训信息记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OaTrainingInfo oaTrainingInfo)
    {
        List<OaTrainingInfo> list = oaTrainingInfoService.selectOaTrainingInfoList(oaTrainingInfo);
        ExcelUtil<OaTrainingInfo> util = new ExcelUtil<OaTrainingInfo>(OaTrainingInfo.class);
        util.exportExcel(response, list, "培训信息记录数据");
    }

    /**
     * 获取培训信息记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(oaTrainingInfoService.selectOaTrainingInfoById(id));
    }

    /**
     * 新增培训信息记录
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:info:add')")
    @Log(title = "培训信息记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JSONObject data)
    {
        return toAjax(oaTrainingInfoService.insertOaTrainingInfo(data));
    }

    /**
     * 修改培训信息记录
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:info:edit')")
    @Log(title = "培训信息记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JSONObject data)
    {
        return toAjax(oaTrainingInfoService.updateOaTrainingInfo(data));
    }

    /**
     * 删除培训信息记录
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:info:remove')")
    @Log(title = "培训信息记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(oaTrainingInfoService.deleteOaTrainingInfoByIds(ids));
    }
}
